﻿<HTML>
<head>
<script type="text/javascript" src="../scripts/context.jsp"></script>
<script type="text/javascript" src="../scripts/cardUtils.js"></script>
<script type="text/javascript" src="../scripts/card.js"></script>
<script type="text/javascript" src="../scripts/jquery.js"></script>
</head>
<body>
<script type="text/javascript">
$(function(){
	$('body').everyTime('3s',test); ;
});
function test(){
	$(this).html(new Date());
}
</script>
<H1>Card Test Page</H1>
<p>You should see your Delphi 7 forms or controls embedded in the
form below.
<hr/>
<center>
<P><script language="javascript">
 /**
  FPortNo,             // 通信端口 1,2,3
  FReaderType,         // 读写器类型 
  FCardType,           // 卡类型：  $41: 表示EM4150卡, $44: 表示EM4469卡.
  FSector,             // 一般情况下，EM4150卡默认为3; EM4469卡默认为5; 
  FBlock:Byte;         // 未用到 ;   客人卡默认0块 
  Hotel:String;        //
  HotelPwd:String;
  LockNo:integer;      //锁号
  CardID:integer;      //卡id
  SubCardID:integer;   //子卡id
  Time:String;        //有效期
  StartSuite:integer;
  EndSuite:integer;  //可开房号
 **/
  function init(){
     bdLockCard.HotelPwd = '11111111';
     bdLockCard.Hotel =  'BTLOCK56';
	 bdLockCard.FPortNo = document.getElementById('FPortNo').value; 
     bdLockCard.FReaderType = document.getElementById('FReaderType').value ;  
	 bdLockCard.FCardType =  document.getElementById('FCardType').value  ; 
	 bdLockCard.FSector = document.getElementById('FSector').value ;
	 bdLockCard.FBlock = 0 ; 
  }
 
  function changeSec(obj){
    if(obj.value=='0'){
        document.getElementById('FSector').value =3;
    }else if(obj.value=='1'){
        document.getElementById('FSector').value =5;
    }
  }
  
  function readCard2(){
      init();
      bdLockCard.readCard();
      document.getElementById('LockNo').value = bdLockCard.LockNo;
      document.getElementById('CardID').value = bdLockCard.CardID; 
      document.getElementById('SubCardID').value = bdLockCard.SubCardID; 
      document.getElementById('FTime').value = bdLockCard.FTime;
      document.getElementById('StartSuite').value = bdLockCard.StartSuite;  
      document.getElementById('EndSuite').value = bdLockCard.EndSuite;   
  }
function read() {
	var r = Card.read();
    document.getElementById('LockNo').value = bdLockCard.LockNo;
    document.getElementById('CardID').value = bdLockCard.CardID; 
    document.getElementById('SubCardID').value = bdLockCard.SubCardID; 
    document.getElementById('FTime').value = bdLockCard.FTime;
    document.getElementById('StartSuite').value = bdLockCard.StartSuite;  
    document.getElementById('EndSuite').value = bdLockCard.EndSuite;   
}
  
  function readSn(){
      init();
      bdLockCard.readSnr();
      document.getElementById('sn').value = bdLockCard.SNR; 
  }

 function writeCard2(){
      init();
      bdLockCard.LockNo  = document.getElementById('LockNo').value   ;
      //bdLockCard.CardID = document.getElementById('CardID').value ; 
     // bdLockCard.SubCardID = document.getElementById('SubCardID').value ; 
      bdLockCard.FTime =document.getElementById('FTime').value;
     // bdLockCard.StartSuite= document.getElementById('StartSuite').value;  
      //bdLockCard.EndSuite=document.getElementById('EndSuite').value;   
      bdLockCard.writeCard(); 
  }
</script>
<body>
<object id="bdLockCard" classid="clsid:130D6F39-2FE2-45FB-92B3-AE73D5B2B4EC"
	codebase="CarMngProj1.ocx" width=0 height=0 align=center hspace=0
	vspace=0> </object>
</br>
<table>
	<tr>
		<td align=right>发卡器类型:</td>
		<td align=left><select id=FReaderType>
			<option value='1'>BTEM232</option>
			<option value='2' selected>BTIB232</option>
		</select></td>
		<td align=right>卡类型：</td>
		<td align=left><select id=FCardType onchange="changeSec(this)">
			<option value='0'>EM4150</option>
			<option value='1' selected>EM4469</option>
		</select></td>
	</tr>
	<tr>
		<td align=right>com:</td>
		<td align=left><select id=FPortNo>
			<option value='1' selected>COM1</option>
			<option value='2'>COM2</option>
			<option value='3'>COM3</option>
			<option value='4'>COM4</option>
		</select></td>
		<td align=right>卡使用地址：</td>
		<td align=left><input id="FSector" type="text" value="5"
			size='10'></td>
	</tr>
	<tr>
		<td align=right>锁号:</td>
		<td align=left><input id="LockNo" type="text" value="" size='10'>
		</td>
		<td align=right>卡号:</td>
		<td align=left><input id="CardID" type="text" value="" size='10'>
		</td>
	</tr>
	<tr>
		<td align=right>子卡号:</td>
		<td align=left><input id="SubCardID" type="text" value=""
			size='10'></td>
		<td align=right>有效日期:</td>
		<td align=left><input id="FTime" type="text" value="" size='10'>
		</td>
	</tr>
	<tr>
		<td align=right>开始号:</td>
		<td align=left><input id="StartSuite" type="text" value=""
			size='10'></td>
		<td align=right>结束号:</td>
		<td align=left><input id="EndSuite" type="text" value=""
			size='10'></td>
	</tr>
	<tr>
		<td align=right>卡序列号:</td>
		<td align=left><input id="sn" type="text" value="" size='10'>
		</td>
	</tr>


</table>
<input name='read' type="button" value='读取' onclick=" readCard2();" />
<input name='write' type="button" value='写入' onclick=" writeCard2();" />
<input name='sn' type="button" value='读取序列号' onclick=" readSn();" />

</body>
</HTML>
